package com.konglz.publisher.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author konglz
 * @Data 2023/5/13 12:30
 */
@RestController
@Api(tags = "发布订阅-广播模式")
@RequestMapping("/fanout")
public class FanoutMessageController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * @Description: 工作队列信息模型案例, 消费者之间属于竞争关系，一个消息只能被一个消费者消费
     * @return: void
     * @Author: konglz
     * @Date: 2023/5/13
     */
    @GetMapping("/{message}")
    @ApiOperation("测试广播模式")
    public void work(@PathVariable String message) {
        String exchangeName = "konglz.fanout";
        rabbitTemplate.convertAndSend(exchangeName,"",message);
    }
}
